#include "StaticSprite.hpp"
#include <iostream>
#include "../Chess.hpp"
#include <cassert>

using namespace std;

StaticSprite::StaticSprite(QPixmap* pixmap, QGraphicsScene* scene, double opacity)
	: QGraphicsItem(0, scene), pixmap(pixmap), opacity(opacity), is_transparent(false)
{
	assert(pixmap != 0);
}

StaticSprite::~StaticSprite()
{}

void StaticSprite::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
	painter->setOpacity(opacity);
		
	if (is_transparent)
		painter->setOpacity(0.5);
			
	painter->drawPixmap(0, 0, *this->pixmap);
}

QRectF StaticSprite::boundingRect() const
{	return pixmap->rect();	}

void StaticSprite::setPixmap(QPixmap*	pix)
{
	assert(pix != 0);
	this->pixmap = pix;
}

void StaticSprite::setTransparent(bool val)
{
	is_transparent = val;
}

